#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> urls(n);
  for (auto& url : urls) {
    int m;
    cin >> m;
    url.resize(m);
    for (auto& x : url) {
      cin >> x;
    }
  }
  vector<int> visited(n + 1);
  visited[1] = true;
  for (auto& id : urls[0]) {
    visited[id] = true;
    for (auto& id2 : urls[id - 1]) {
      visited[id2] = true;
    }
  }
  int res = 0;
  for (auto& v : visited) {
    res += v;
  }
  cout << res << endl;
  return 0;
}